//
//  DMYVisitorView.swift
//  swiftWB
//
//  Created by mongyuan on 16/8/11.
//  Copyright © 2016年 Apple. All rights reserved.
//

import UIKit

class DMYVisitorView: UIView {

    // MARK: - 提供快速通过xib创建的类方法
    class func visitorView() -> DMYVisitorView {
        return NSBundle.mainBundle().loadNibNamed("DMYVisitorView", owner: nil, options: nil).first as! DMYVisitorView
    }
    
    // MARK: - 属性列表
    @IBOutlet weak var roationImage: UIImageView!
    @IBOutlet weak var iconImage: UIImageView!
    @IBOutlet weak var desLabel: UILabel!
    
    // MARK: - 自定义函数
    func setUpView(title : String, imageName : String) {
        iconImage.image = UIImage(named: imageName)
        desLabel.text = title
        roationImage.hidden = true
    }

    // MARK：- 动画旋转
    func addAnimation() {
        // 1.创建动画
        let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
        
        // 2.设置动画的属性
        rotationAnimation.fromValue = 0
        rotationAnimation.toValue = 2 * M_PI
        rotationAnimation.repeatCount = MAXFLOAT
        rotationAnimation.duration = 6
        rotationAnimation.removedOnCompletion = false
        
        // 3.将动画添加到layer中
        roationImage.layer.addAnimation(rotationAnimation, forKey: nil)
    }
}
